<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="发行方名称">
              <a-input placeholder="请输入发行方名称" v-model="queryParam.issuerName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="展会主题">
              <a-input placeholder="请输入展会主题" v-model="queryParam.worksNumber"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button type="primary" icon="download" style="margin-left: 8px" @click="handleExportXls('发行方登记')">导出</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <template slot="oldSlot" slot-scope="text,record">
          <ul style="list-style: none;padding: 0;margin:0;">
            <li v-for="(val,index) in text.split(',')">
              <span>{{val}}</span>
              <span v-if="text" style="color:#F5222D;cursor: pointer;margin-right:10px;float: right;" @click="oldNewCli(record.worksIds,index)"> 详情 </span>
            </li>
          </ul>
        </template>
        <template slot="newSlot" slot-scope="text,record">
          <ul style="list-style: none;padding: 0;margin:0;">
            <li v-for="(val,index) in text.split(',')">
              <span>{{val}}</span>
              <span v-if="text" style="color:#F5222D;cursor: pointer;margin-right:10px;float: right;" @click="oldNewCli(record.newWorksIds,index)"> 详情 </span>
            </li>
          </ul>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" v-if="!(userAuth2btn == '1' && record.status!=0)">编辑</a>
          <a-divider type="vertical"  v-if="!(userAuth2btn == '1' && record.status!=0)"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <exhibition_issuer_register-modal ref="modalForm" @ok="modalFormOk"></exhibition_issuer_register-modal>
    <BlockProductStandardsAll v-if="showAll" :listData="listData" @returnUp="returnUp"></BlockProductStandardsAll>    
  </a-card>
</template>

<script>
  import Exhibition_issuer_registerModal from './modules/Exhibition_issuer_registerModal'
  import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { postAction,getAction } from '@/api/manage'
  import BlockProductStandardsAll from '../exhibition/modules/BlockProductStandardsAll'

  export default {
    name: "Exhibition_issuer_registerList_after_admin",
    mixins:[JeecgListMixin],
    components: {
      Exhibition_issuer_registerModal,
      BlockProductStandardsAll
    },
    data () {
      return {
        description: '发行方登记管理页面',
        showAll:false,
        listData:{},
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   {
            title: '发行方名称',
            align:"center",
            dataIndex: 'issuerName'
           },
		   {
            title: '展会主题',
            align:"center",
            dataIndex: 'theme'
           },
           {
             title: '在售作品',
            align:"center",
            dataIndex: 'worksIdsName',
            scopedSlots: { customRender: 'oldSlot' }
           },
           {
             title: '预售作品',
            align:"center",
            dataIndex: 'newWorksIdsName',
            scopedSlots: { customRender: 'newSlot' }
           },
          {
            title: '展位码',
            align:"center",
            dataIndex: 'boothNum'
          },
		       {
            title: '手机号',
            align:"center",
            dataIndex: 'phone'
           },
          //  {
          //   title: '二维码',
          //   align:"center",
          //   dataIndex: 'worksIds'
          //  },
		   {
            title: '审核状态',
            align:"center",
            dataIndex: 'status',
            customRender: text => {
              return filterMultiDictText(this.dictOptions['applyStatus'], text + '')
            }            
           }
        ],
    userAuth2btn:"1",
		url: {
        list: "/exhibition/exhibition_issuer_register/list",
        delete: "/exhibition/exhibition_issuer_register/delete",
        deleteBatch: "/exhibition/exhibition_issuer_register/deleteBatch",
        exportXlsUrl: "exhibition/exhibition_issuer_register/exportXls",
        importExcelUrl: "exhibition/exhibition_issuer_register/importExcel",
        apply:"/exhibition/exhibition_issuer_register/audit"
      },
    dictOptions: {
      applyStatus: []
    },
    }
  },
  mounted(){
    getAction("/block/blockManufacturerInfo/userAuth2btn")
        .then(res => {
          if (res.success) {
            this.userAuth2btn = res.result.status;
          } else {
            that.$message.warning(res.message)
          }
        })
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    oldNewCli(list,index){      
        var pams = {
          id:list.split(',')[index]
        }
      getAction("/exhibition/exhibition_product_standards_new/list",pams)
        .then(res => {
          if (res.success) {
            this.showAll = true;
            this.listData = res.result.records[0];
          } else {
            that.$message.warning(res.message)
          }
        })
    },
    initDictConfig() {
      initDictOptions('apply_status').then(res => {
        if (res.success) {
          this.$set(this.dictOptions, 'applyStatus', res.result)
        }
      })
    },
    detailsCli(record){
      this.showAll=true;
      this.listData = record;
    },
    returnUp(data){
      this.showAll = data;
    },
    handleApplyYes(){
      this.applyMethod(this, 1)
    },
    handleApplyNo(){
      this.applyMethod(this, 0)
    },
    applyMethod(that, status) {
      var ids = '';
      if (that.selectedRowKeys.length <= 0) {
        that.$message.warning('请选择一条记录！')
        return
      }
      for (var a = 0; a < that.selectedRowKeys.length; a++) {
        if(a == 0){
          ids += that.selectedRowKeys[a];
        }else{
          ids += ',' + that.selectedRowKeys[a];
        }
      }
      postAction(that.url.apply, { "id": ids, "status": status })
        .then(res => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
            that.onClearSelected()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.loading = false
        })
    },
  }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>